<template>
	<view class="user-chat-item">
		<!-- 聊天时间 -->
		<view v-if="item.gstime" class="user-chat-time u-f-ajc">{{item.gstime}}</view>
		<view class="user-chat-list u-f" :class="item.isme ? 'user-chat-me' : ''">
			<image v-if="!item.isme" :src="item.avatar" mode="widthFix" lazy-load></image>
			<view class="user-chat-list-body">
				<text v-if="item.type === 'text'">{{item.data}}</text>
				<image v-else :src="item.data" mode="widthFix" lazy-load></image>
			</view>
			<image v-if="item.isme" :src="item.avatar" mode="widthFix" lazy-load></image>
		</view>
	</view>
</template>

<script>
	export default{
		props: {
			item: Object,
			index: Number
		}
	}
</script>

<style scoped>
	.user-chat-time{
		padding: 50upx 0;
		color: #A2A2A2;
	}
	
	.user-chat-list{
		margin: 20upx 0;
		padding: 10upx 20upx;
	}
	.user-chat-list>image{
		width: 100upx;
		height: 100upx;
		border-radius: 100%;
		flex-shrink: 0;
	}
	.user-chat-list-body{
		position: relative;
		background: #F4F4F4;
		padding: 25upx;
		border-radius: 10upx;
		margin-left: 20upx;
		margin-right: 100upx;
	}
	.user-chat-list-body:after{
		position: absolute;
		left: -30upx;
		right: 0;
		top: 30upx;
		content: '';
		width: 0;
		height: 0;
		border: 16upx solid #F4F4F4;
		border-color: transparent #F4F4F4 transparent transparent;
	}
	.user-chat-list-body>image{
		max-width: 200upx;
		max-height: 400upx;
	}
	
	.user-chat-me{
		justify-content: flex-end;
	}
	.user-chat-me .user-chat-list-body{
		margin-right: 20upx;
		margin-left: 100upx;
		background: #cbeacd;
	}
	.user-chat-me .user-chat-list-body:after{
		left: auto;
		right: -30upx;
		border-color: transparent transparent transparent #cbeacd;
	}
</style>
